package main

import "fmt"

// 定义状态变量
const (
	Initial = iota // 初始状态
	ID             // 原始状态
	Num
	GT
	GE
)

func isNum(c rune) bool {
	if c >= '0' && c <= '9' {
		return true
	}
	return false
}

func isAlpha(c rune) bool {
	if (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') {
		return true
	}
	return false
}



func main() {
	// 读取输入的文本
	_srcRawLine := "age12>=45" + "\n"
	var _state = Initial
	var _outToken = ""

	for _, _char := range _srcRawLine {
		var _doTwice = false
		for {
			switch _state {
			case Initial:
				_doTwice = true
				_outToken = ""
				if isNum(_char) {
					_state = Num
				} else if isAlpha(_char) {
					_state = ID
				} else if _char == '>' {
					_state = GT
				}
				_outToken += string(_char)
				break
			case ID:
				if isAlpha(_char) || isNum(_char) || _char == '_' {
					_outToken += string(_char)
				} else {
					fmt.Println("ID", _outToken)
					_state = Initial
				}
				break
			case Num:
				if isNum(_char) {
					_outToken += string(_char)
				} else {
					fmt.Println("Num", _outToken)
					_state = Initial
				}
				break
			case GT:
				if _char == '=' {
					_outToken += string(_char)
					_state = GE
				} else {
					fmt.Println("OP", _outToken)
					_state = Initial
				}
				break
			case GE:
				fmt.Println("OP", _outToken)
				_state = Initial
				break
			}

			if _state != Initial || _doTwice {
				break
			}
		}
	}

	//结束时输出

	// switch _state {
	// case ID:
	// 	fmt.Println("ID", _outToken)
	// 	break
	// case Num:
	// 	fmt.Println("Num", _outToken)
	// 	break
	// case GT:
	// 	fmt.Println("OP", _outToken)
	// 	break
	// case GE:
	// 	fmt.Println("OP", _outToken)
	// 	break
	// }

}
